import request from '../../utils/request';
import store from '../../store/index';

// 获取音乐列表
export function getSongSheetList(singerId = '') {
  const payload = {
    splid: store.state.live.liveId,
  };
  if (singerId) {
    payload.singerId = singerId;
  }
  return request.post('music/list', payload, { useCache: true });
}

// 获取来宾点歌信息列表
export function getSongOrderedList(singerId = '') {
  const payload = {
    splid: store.state.live.liveId,
    type: 'Music',
    is_delete: '0',
  };
  if (singerId) {
    payload.singerId = singerId;
  }
  return request.post('music/musicList', payload);
}

// 点歌 (打包更丰富的表单信息)
export function orderSong({
  songId, deskNum, nickname, blessing,
}) {
  const extraInfo = {
    deskNum,
    nickname,
    bless: blessing,
  };

  return request.post('music/sendMusic', {
    splid: store.state.live.liveId,
    type: 'Music',
    id: songId,
    photo_end_url: JSON.stringify(extraInfo),
  });
}

// 获取歌手列表
export function getSingerList() {
  return request.post(
    'music/singerList',
    {
      splid: store.state.live.liveId,
    },
    { useCache: true },
  );
}
